﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using University.Workshop.Model;
using University.Workshop.DataAccess;

namespace University.Workshop.Business
{
    public static class PatientManager
    {
        public static bool MandatoryFields(Patient patient)
        {
            if (patient != null)
            {
                if ((string.IsNullOrEmpty(patient.PatientId)) || (string.IsNullOrEmpty(patient.FirstName)) || string.IsNullOrEmpty(patient.FatherLastName) || (string.IsNullOrEmpty(patient.MotherLastName)) || string.IsNullOrEmpty(patient.LandPhone) || string.IsNullOrEmpty(patient.CellPhone) || string.IsNullOrEmpty(patient.Address))
                    return false;
                else
                    return true;
            }
            else return false;
        }

        public static bool CleanSpaces(string message)
        {
            if (message == "All fields are obligatory")
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public static void PatientRegister(Patient patient)
        {
            if (!PatientDataAccess.PatientRegister(patient))
                throw new InvalidOperationException ("The patient is already register");
        }

        public static ICollection<Patient> SearchPatient(string lastName)
        {
            return PatientDataAccess.SearchPatient(lastName);
        }

        public static Patient ShowPatient(string idPatient)
        {
            Patient patient = PatientDataAccess.ShowPatient(idPatient);
            return patient;
        }

        public static bool PatientExists(string patientId)
        {
            return DataAccess.PatientDataAccess.PatientExists(patientId);
        }
    }
}
